import wx
from random import randint

class MyFrame(wx.Frame):
    def __init__(self,parent,id,title):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(250,270))
        str1 = str(randint(2,9))
        self.panel = wx.Panel(self,-1,(75,20),(100,127), style=wx.SUNKEN_BORDER)
        self.button3 = wx.Button(self.panel, 1, 'DICE', (75, 100))
        self.label1 = wx.StaticText(self.panel, -1, str1 , wx.Point(15, 30))
        self.label1.SetLabel(str(randint(2,9)))
        self.button3.Bind(wx.EVT_BUTTON, self.button3Click)

    def button3Click(self,event):
        self.label1.SetLabel(str(randint(2,9)))

class MyApp(wx.App):
    def OnInit(self):
        myframe = MyFrame(None, -1, "test")
        myframe.CenterOnScreen()
        myframe.Show(True)
        return True

app = MyApp(0)
app.MainLoop()